﻿using MiniBottles.Models;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.Mvc;

namespace MiniBottles.Controllers
{
    [Authorize]
    public class AdministrationController : Controller
    {
        private DataContext db = new DataContext();
        //
        // GET: /Administration/

        public ActionResult Index()
        {
            return RedirectToAction("Index", "Bottle");
        }
        [ChildActionOnly]
        public ActionResult Menu()
        {
            ViewBag.Collections = db.DictCollection.Where(x=>!x.IsDeleted && x.IsActive).OrderBy(x=> x.Name).ToList();
            
            return PartialView("_AdminMenu");
        }
        public ActionResult GuestBook()
        {
            return View(db.GuestBooks.Where(x => !x.IsDeleted).ToList());
        }
        public ActionResult DeleteComment(int id)
        {
            GuestBook comment = db.GuestBooks.Find(id);
            db.GuestBooks.Remove(comment);
            db.SaveChanges();
            return RedirectToAction("GuestBook");
        }
    }
}
